/* Copyright (c) 2004-2024 Peigen.info. All rights reserved. */

package info.peigen.hotpot.business.fee.core.domain.action;

import info.peigen.hotpot.business.fee.core.domain.Fee;
import info.peigen.hotpot.business.fee.core.domain.FeeLog;
import info.peigen.hotpot.business.fee.core.domain.FeeRule;
import info.peigen.hotpot.business.fee.facade.command.order.FeeOrder;

/**
 * <b>(FeeDomainAction)</b>
 *
 * @author Peigen
 * @version 1.0.0
 * @since 2021/8/12
 */
public class FeeDomainAction {
    public static Fee active(FeeOrder order, FeeRule rule) {
        return Fee.builder()
                .action(order.getAction())
                .code(order.getCode())
                .tradeId(order.getTradeId())
                .transAmount(order.getTransAmount())
                .memo(order.getMemo())
                .feeLog(FeeLog.builder().action(order.getAction())
                        .account(rule.getAccount())
                        .memo(order.getMemo())
                        .tradeId(order.getTradeId())
                        .code(order.getCode()).build()
                        .setRule(rule))
                .rule(rule)
                .calculateAccount(rule.getAccount())
                .billingAccount(rule.getBillingAccount())
                .chargeAccount(rule.getPayerAccount())
                .feeAccount(rule.getPayeeAccount())
                .build();
    }
}
